<?php
$section = 'booking';

$titre = _LB_BOOKING_MANAGEMENT;
$smarty->assign("titre", $titre);

$backlink = Session::getBackLink($section,"list/?");
$id = Request::getNumber("id");
$act = Request::getIntNumber('act');

$booking = new Booking();
if($id <=0 || !$booking->get($id)){
	redirect(APPLICATION_URL."/");
}
if ($act == ACT_VALID_EDIT)
{
	$status = Request::getIntNumber('STATUS');
	if($status ==1 || $status ==2){
		$booking->STATUS = $status;
		if($booking->update()){
			$mailNotify = new Mail_Notify();
			$mailNotify->ID_BOOKING = $id;
			$mailNotify->STATUS = $status;
			if($status == 2){
				$mailNotify->REASON = Request::get('REASON');
			}
			$mailNotify->insert();
		}
	}
	redirect($backlink);
}

$bookingData = Booking_detail::getbookingDetail($id);

$cfer = new Cfer(array(
	_LB_ACCUEIL => Utils::getHomeLink(),
	_LB_BOOKING_MANAGEMENT => Utils::getCurrentLink()));

$smarty->assign('cfer', $cfer);
$smarty->assign('bookingData', $bookingData[$id]);
$smarty->assign('backlink', $backlink);
$smarty->display('booking_detail.html');

